package advancewars.core.unit.imp;

import java.util.List;

import advancewars.core.unit.ICommandOfficer;
import advancewars.core.unit.IProvision;
import advancewars.core.unit.IUnit;
import advancewars.core.unit.IWeapon;

public abstract class AbstractUnit implements IUnit
{
	int healthPoint; // health point
	int maxHealthPoint;
	int moveRange;
	int visionRange;

	IProvision provision;
	ICommandOfficer commandOfficer;
	List<IWeapon> weaponList;

	public AbstractUnit(ICommandOfficer commandOfficer)
	{
		super();
		this.commandOfficer = commandOfficer;
	}

	@Override
	public void consume(int usage)
	{
		provision.consume(usage);
		if (provision.getProvisionAmount() <= 0)
		{
			this.selfdestroy();
		}
	}

	@Override
	public ICommandOfficer getCommandOfficer()
	{
		return this.commandOfficer;
	}

	public int getHealthPoint()
	{
		return healthPoint;
	}

	@Override
	public int getHP()
	{
		return 10 * healthPoint / maxHealthPoint;
	}

	public int getMaxHealthPoint()
	{
		return maxHealthPoint;
	}

	@Override
	public int getMaxHP()
	{
		return 10;
	}

	@Override
	public int getMoveRange()
	{
		return moveRange;
	}

	public int getVisionRange()
	{
		return visionRange;
	}

	public List<IWeapon> getWeaponList()
	{
		return weaponList;
	}

	@Override
	public void loseHP(int damage)
	{
		healthPoint = healthPoint - damage;
		if (healthPoint <= 0)
		{
			this.selfdestroy();
		}

	}

	@Override
	public void selfdestroy()
	{
		// TODO Auto-generated method stub

	}

	void setCommandOfficer(ICommandOfficer commandOfficer)
	{
		this.commandOfficer = commandOfficer;
	}

	void setHealthPoint(int healthPoint)
	{
		this.healthPoint = healthPoint;
	}

	void setMaxHealthPoint(int maxHealthPoint)
	{
		this.maxHealthPoint = maxHealthPoint;
	}

	void setMoveRange(int moveRange)
	{
		this.moveRange = moveRange;
	}

	void setVisionRange(int visionRange)
	{
		this.visionRange = visionRange;
	}

	void setWeaponList(List<IWeapon> weaponList)
	{
		this.weaponList = weaponList;
	}

}
